/*******************************************************************************
 * Copyright 2011 Mauro Luigi Drago (drago.luigi@gmail.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package com.bytenose.extrautils.logging;

import com.bytenose.extrautils.annotations.NonNullable;

/**
 * An error aware logger.
 * @author Mauro Luigi Drago.
 *
 * @param <ErrorType> the type of errors to log.
 */
public interface IErrorLogger<ErrorType> extends ILogger {
	/**
	 * Logs an error.
	 * 
	 * @param error the error, cannot be null.
	 * @throws IllegalArgumentException
	 *		if some of the non nullable arguments are null.
	 */
	void logError(@NonNullable ErrorType error)
			throws IllegalArgumentException;
	
	/**
	 * Saves an error in the errors collection
	 * without logging it.
	 * 
	 * @param error the error, cannot be null.
	 * @throws IllegalArgumentException
	 *		if some of the non nullable arguments are null.
	 */
	void addError(@NonNullable ErrorType error)
			throws IllegalArgumentException;
	
	/**
	 * Saves an error in the errors collection and logs it.
	 * 
	 * @param error the error, cannot be null.
	 * @throws IllegalArgumentException
	 *		if some of the non nullable arguments are null.
	 */
	void logAddError(@NonNullable ErrorType error)
			throws IllegalArgumentException;
	
	/**
	 * Logs a collection of errors.
	 * 
	 * @param errors the errors, cannot be null.
	 * @throws IllegalArgumentException
	 *		if some of the non nullable arguments are null.
	 */
	void logErrors(@NonNullable Iterable<? extends ErrorType> errors)
			throws IllegalArgumentException;
	
	/**
	 * Saves a collection of errors in the errors collection
	 * without logging them.
	 * 
	 * @param errors the errors, cannot be null.
	 * @throws IllegalArgumentException
	 *		if some of the non nullable arguments are null.
	 */
	void addErrors(@NonNullable Iterable<? extends ErrorType> errors)
			throws IllegalArgumentException;
	
	/**
	 * Saves and logs a collection of errors in the errors collection.
	 * 
	 * @param errors the errors, cannot be null.
	 * @throws IllegalArgumentException
	 *		if some of the non nullable arguments are null.
	 */
	void logAddErrors(@NonNullable Iterable<? extends ErrorType> errors)
			throws IllegalArgumentException;
	
	/**
	 * Gets all the collected errors.
	 * 
	 * @return the errors
	 */
	@NonNullable Iterable<ErrorType> getErrors();
	
	/**
	 * Checks if some errors were collected.
	 * 
	 * @return true if some were collected, false otherwise.
	 */
	boolean isErroneous();
}
